package com.miao.teacher.adapter;

import com.miao.teacher.models.PullOrder;
import com.miao.teacher.ui.R;
import com.miao.teacher.utils.ConvertUtils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class OrderAdapter extends BaseAdapter{
	private Context context=null;
	private PullOrder []mList=null;
	
	private LayoutInflater mInflater;
	public OrderAdapter(Context c,PullOrder []list)
	{
		context=c;
		mList=list;
		mInflater = (LayoutInflater) context
		.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if(mList==null)
		{
			return 0;
		}
		return mList.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		if(mList==null)
		{
			return null;
		}
		return mList[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_revise, null);
			holder = new ViewHolder();
			holder.tvOrder=(TextView)convertView.findViewById(R.id.tvOrder);
			holder.tvTitle=(TextView)convertView.findViewById(R.id.tvTitle);
			holder.tvTime=(TextView)convertView.findViewById(R.id.tvTime);
			convertView.setTag(holder);
		}else
		{
			holder = (ViewHolder) convertView.getTag();
		}
		PullOrder obj=mList[arg0];
		holder.tvOrder.setText((arg0+1)+"");
		holder.tvTitle.setText(obj.title);
		holder.tvTime.setText(ConvertUtils.getWebTime(obj.created_at));
		return convertView;
	}
	static class ViewHolder
	{
		TextView tvOrder;
		TextView tvTitle;
		TextView tvTime;
	}
}
